home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8018 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: merge algorithm
  5. Date: 28 Feb 1996 15:44:31 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4h2pcvINN3be@anvil.ugrad.cs.ubc.ca>
  8. References: <312CEE69.842@onyx.idbsu.edu>
  9. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  10.  
  11. In article <312CEE69.842@onyx.idbsu.edu>,
  12. Joe E. Coffland <jcofflan@onyx.idbsu.edu> wrote:
  13.  >I am trying to find an algorithm to merge two sorted arrays containing
  14.  >n elements.
  15.  >ie. A[1] <= A[2]<= ... <= A[m] and A[m+1] <= A[m+2] <= ... <A[n]
  16.  >The algorithm must run in O(n) time and require only a small amount of
  17.  >fixed additional memory regardless of the size of m or n. I have reason
  18.  >to believe that there is such an algorithm but I have only been able to
  19.  >find algorithms that meet the memory restriction but run in at best
  20.  >O(nlogn) and are recursive (which can through some work of course be
  21.  >changed in to an iterative algorithm). If any one can point me to a book
  22.  >or any other source of information on the subject or just get me headed
  23.  >in the right direction it would be greatly appriciated.
  24.  
  25. That's an interesting problem. One possible ``lead'' might be to reverse one of
  26. the arrays in place first, and then look for solutions given that arrangement
  27. of things. 
  28. -- 
  29.  
  30.